<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改招募团队文案')" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-recruitTeam-edit" th:object="${recruitTeam}">
        <input name="id" th:field="*{id}" type="hidden">

        <div class="form-group">
            <label class="col-sm-3 control-label">标题：</label>
            <div class="col-sm-8">
                <input name="title" th:field="*{title}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">文案类型：</label>
            <div class="col-sm-8" th:if="*{type+'' == '0'}">
                <div class="radio-box" >
                    <input type="radio" name="type" value="0" checked="checked">
                    <label  th:text="钱展业端管理"></label>
                </div>
                <div class="radio-box">
                        <input type="radio" name="type" value="1" >
                    <label  th:text="商钱付"></label>
                 </div>
            </div>
            <div class="col-sm-8" th:if="*{type+'' == '1'}">
                <div class="radio-box" >
                    <input type="radio" name="type" value="0" >
                    <label  th:text="钱展业端管理"></label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="type" value="1" checked="checked">
                    <label  th:text="商钱付"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">封面图：</label>
            <div class="col-sm-8">
                <div class="fileinput fileinput-new" data-provides="fileinput">
                    <div class="fileinput-new thumbnail" style="width: 140px; height: 140px;">
                        <img th:src="*{imgUrl}">
                    </div>
                    <div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;"></div>
                    <div>
                        <span class="btn btn-white btn-file"><span class="fileinput-new">选择图片</span><span class="fileinput-exists">更改</span>
                            <input type="file" name="typePic" accept="image/*"></span>
                        <a href="#" class="btn btn-white fileinput-exists" data-dismiss="fileinput">清除</a>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">发布状态：</label>
            <div class="col-sm-8" th:if="*{is_publish+'' == '0'}">
                <div class="radio-box" >
                    <input type="radio" name="is_publish" value="0" checked="checked">
                    <label  th:text="未发布"></label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="is_publish" value="1" >
                    <label  th:text="已发布"></label>
                </div>
            </div>
            <div class="col-sm-8" th:if="*{is_publish+'' == '1'}">
                <div class="radio-box" >
                    <input type="radio" name="is_publish" value="0" >
                    <label  th:text="未发布"></label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="is_publish" value="1" checked="checked">
                    <label  th:text="已发布"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">消息內容：</label>
            <div class="col-sm-8" >
                <textarea rows="10" cols="10"  th:field="*{msg}" name="msg"  class="form-control"></textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: jasny-bootstrap-js" />
<th:block th:include="include :: summernote-js" />
<script th:inline="javascript">
    var prefix = ctx + "recruitTeam/recruitTeam";
    $("#form-recruitTeam-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            // $.operate.save(prefix + "/edit", $('#form-recruitTeam-edit').serialize());
            var formData = new FormData();
            if (undefined==$("[name='typePic']").get(0)){
                $.modal.alertWarning("请上传招募文案")
            }else{
                formData.append("typePic", $("[name='typePic']").get(0).files[0]);
            }

            var realName=$("[name='realName']").val();
            formData.append("realName",realName);
            formData.append("type",$("[name='type']:checked").val());
            var msg=$("[name='msg']").val();
            formData.append("msg",msg);
            var title=$("[name='title']").val();
            formData.append("title",title);
            var is_publish=$("[name='is_publish']:checked").val();
            formData.append("is_publish",is_publish);
            var id=$("[name='id']").val();
            formData.append("id",id);
            if ($.common.isNotEmpty(msg) && msg.length > 100){
                $.modal.alertError("内容长度不能大于100");
                return;
            }
            $.ajax({
                url : prefix + "/edit",
                type: 'POST',
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                beforeSend: function () {
                    $.modal.loading("正在处理中，请稍后...");
                    $.modal.disable();
                },
                success : function(result) {
                    if (result.code == web_status.SUCCESS) {
                        var parent = window.parent;
                        if (parent.table.options.type == table_type.bootstrapTable) {
                            $.modal.close();
                            parent.$.modal.msgSuccess(result.msg);
                            parent.$.table.refresh();
                        } else if (parent.table.options.type == table_type.bootstrapTreeTable) {
                            $.modal.close();
                            parent.$.modal.msgSuccess(result.msg);
                            parent.$.treeTable.refresh();
                        } else {
                            $.modal.msgReload("保存成功,正在刷新数据请稍后……", modal_status.SUCCESS);
                        }
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    }  else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                    $.modal.enable();
                    //$.modal.alertSuccess(data.msg)
                },
                error : function(result) {
                    $.modal.alertError(result.msg);
                }
            });
        }
    }


    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });
    var edit = function () {
        $("#eg").addClass("no-padding");
        $('.click2edit').summernote({
            lang: 'zh-CN',
            focus: true
        });
    };
    var save = function () {
        $("#eg").removeClass("no-padding");
        var aHTML = $('.click2edit').summernote('code');
        $('.click2edit').summernote('destroy');
    };
</script>
</body>
</html>